<?xml version="1.0"?>
<Model name="euclid">

  <TypeDef name="uint16" type="unsigned" width="16"/>
  <TypeDef name="small" type="unsigned" width="2"/>
	
	<Module name="simple">
	<Datapath>
		<!-- Connectors -->
		<Connector name="a_in" kind="queue" direction="in" type="uint16"/>
		<Connector name="b_out" kind="queue" direction="out" type="uint16"/>
					
		<Register name="count" type="uint16"/>
																			
		<SignalFlowGraph name="display_value">		
			<Expression>
				$display(a_in);
			</Expression>			
		</SignalFlowGraph>		
		
		<SignalFlowGraph name="run">		
			<Expression>
				b_out = 0x11;
			</Expression>			
		</SignalFlowGraph>			
		
		<SignalFlowGraph name="docount">		
			<Expression>
				count = count + 1;
			</Expression>		
			<Expression>
				$display(count)
			</Expression>						
		</SignalFlowGraph>		
		
		<SignalFlowGraph name="reset">		
			<Expression>
				count = 0;
			</Expression>			
		</SignalFlowGraph>						
		
		</Datapath>
		<Controller>
		<State name="s1" initial="true"/>	
		<State name="s0"/>
		<State name="s2"/>

		<TransitionSet source="s1">		
			<Transition target="s0">			
				<Condition>
					<Expression>
						count > 10;
					</Expression>
				</Condition>
				<ExecutionSet>
					<SignalFlowGraphRef name="run"/>
					<SignalFlowGraphRef name="reset"/>				
				</ExecutionSet>
			</Transition>
			 			
			<Transition target="s1">
				<ExecutionSet>
					<SignalFlowGraphRef name="docount"/>				
				</ExecutionSet>
			</Transition>
		</TransitionSet>	

		<TransitionSet source="s0">		
			<Wait target="s1">
				<QueueReadyEvent name="a_in"/>
			</Wait>
		</TransitionSet>
											
		<TransitionSet source="s2">													
			<Transition target="s1">
				<ExecutionSet>
					<SignalFlowGraphRef name="display_value"/>				
				</ExecutionSet>
			</Transition>
		</TransitionSet>
																		
	</Controller>
	</Module>
	
	
	<Module name="test_simple">
	<Datapath>
		<Connector name="a_out" kind="queue" direction="out" type="uint16"/>
		<Connector name="b_in" kind="queue" direction="in" type="uint16"/>

		<SignalFlowGraph name="sfg1">		
			
			<Expression>
				a_out = b_in;		
			</Expression>			
			<Expression>
				$display("a_out: ", a_out);		
			</Expression>
				
		</SignalFlowGraph>				
	</Datapath>

	<Controller>
		<State name="s0" initial="true"/>		
		<State name="s1"/>
		
		<TransitionSet source="s0">		
			<Wait target="s1">
				<QueueReadyEvent name="b_in"/>
			</Wait>
		</TransitionSet>
		
		<TransitionSet source="s1">			
			<Transition target="s0">
				<ExecutionSet>
			 		<SignalFlowGraphRef name="sfg1"/>			 
				</ExecutionSet>	
			</Transition>
		</TransitionSet>				
		
	</Controller>
	</Module>
	
	
	<System name="S">
		<!-- connection name is optional -->
		<Queue name="a" type="uint16" length="1"/>
		<Queue name="b" type="uint16" length="1"/>
		
		<Use name="SIMPLE" entity="simple">
			<Connect connector="a_in"  channel="a"/>
			<Connect connector="b_out" channel="b"/>
		</Use>
		
		<Use name="TEST_SIMPLE" entity="test_simple">
			<Connect connector="a_out" channel="a"/>
			<Connect connector="b_in" channel="b"/>
		</Use>				
	</System>
</Model>
